// 转化日期
const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}


   // 转化金额的点数
  const  getFloatStr=(num)=>{  
    num += '';  
    num = num.replace(/[^0-9|\.]/g, ''); 
      
    if(/^0+/) 
        num = num.replace(/^0+/, '');  
   if(!/\./.test(num)) 
       num += '.00';  
   if(/^\./.test(num))   
       num = '0' + num;  
   num += '00';      
   num = num.match(/\d+\.\d{2}/)[0];
   return num
   }

// 日期转化
let dateConversion=(value)=>{
  var d = new Date(value);
  var date =
      d.getFullYear() +
      "-" +
      (d.getMonth() + 1) +
      "-" +
      d.getDate() +
      " " +
      d.getHours() +
      ":" +
      d.getMinutes() +
      ":" +
      d.getSeconds();
  return date;
}

module.exports = {
  formatTime,
  dateConversion,
  getFloatStr
}
